<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>树网格之操作 - jQuery EasyUI 演示</title>
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../../jquery.min.js"></script>
	<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
	<h2 title="TreeGrid Actions">树网格之操作</h2>
	<p title="Click the buttons below to perform actions.">　　点击下面的按钮即可执行相应的操作。　　
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="collapseAll()">全缩</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="expandAll()">全展</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="expandTo()">展至特定值</a> <sup onclick="alert(title)" title="码名：22 分析">*</sup>
	</p>
	<table id="tg" class="easyui-treegrid" title="<ch title='TreeGrid Actions'>&nbsp;树网格之操作</ch>" style="width:700px;height:260px"
			data-options="
				iconCls: 'icon-ok',
				rownumbers: true,
				animate: true,
				collapsible: true,
				fitColumns: true,
				url: 'treegrid_data2.json',
				method: 'get',
				idField: 'id',
				treeField: 'name'
			">
		<thead>
			<tr>
				<th data-options="field:'name',width:180,halign:'center'"><h title="Task Name">工程项目</h></th>
				<th data-options="field:'persons',width:60,align:'right',halign:'center'"><h title="Persons">投入人力</h></th>
				<th data-options="field:'begin',width:80,align:'center'"><h title="Begin Date">开工日期</h></th>
				<th data-options="field:'end',width:80,align:'center'"><h title="End Date">竣工日期</h></th>
				<th data-options="field:'progress',width:120,formatter:formatProgress,halign:'center'"><h title="Progress">当前施工进度</h></th>
			</tr>
		</thead>
	</table>
	<script type="text/javascript">
		function formatProgress(value){
	    	if (value){
		    	var s = '<div style="width:100%;border:1px solid #ccc">' +
		    			'<div style="text-align:right; width:' + value + '%;background:#cc0000;color:#fff">' + value + '％' + '</div>'
		    			'</div>';
		    	return s;
	    	} else {return '';}
		}
		function collapseAll(){$('#tg').treegrid('collapseAll');}
		function expandAll(){$('#tg').treegrid('expandAll');}
		function expandTo(){$('#tg').treegrid('expandTo',22).treegrid('select',22);}
	</script>
</body>
</html>